<template>
  <el-dialog
    width="30%"
    :title="params.title"
    :visible.sync="params.visible"
  >
    <el-row class="row-bg">
      <el-checkbox-group v-model="checkList">
        <el-col v-for="i in checkDate" :key="i" :span="8">
          <el-checkbox :label="i" />
        </el-col>
      </el-checkbox-group>
    </el-row>
    <span
      slot="footer"
      class="dialog-footer"
    >
      <dialog-btn />

    </span>
  </el-dialog>
</template>
<script>
export default {
  name: 'CheckboxDialog',
  props: {
    // eslint-disable-next-line vue/require-default-prop
    params: {
      type: Object,
      default() {
        return {
          visible: false,
          title: '', // 标题
          checkList: '', // 选择数据
          checkData: ''// 渲染得数据
        }
      }
    }
  },
  data() {
    return {
      checkList: [],
      checkDate: []
    }
  },
  created() {
    this.checkList = this.params.checkList
    this.checkDate = this.params.checkDate
  },
  methods: {
    confirm() {
      // 如果当前传入回调则使用回调
      if (this.params.confirm !== undefined) {
        this.params.confirm(this.checkList)
      } else {
        this.$emit('confirm', this.checkList)
      }
    }
  }
}
</script>
